home *** CD-ROM | disk | FTP | other *** search
- /*
- * $RCSfile: analyzePageAllocation.c,v $
- * $Revision: 1.1.1.1 $
- * $Date: 1996/05/04 21:55:33 $
- */
- /**********************************************************************
- * EXODUS Database Toolkit Software
- * Copyright (c) 1991 Computer Sciences Department, University of
- * Wisconsin -- Madison
- * All Rights Reserved.
- *
- * Permission to use, copy, modify and distribute this software and its
- * documentation is hereby granted, provided that both the copyright
- * notice and this permission notice appear in all copies of the
- * software, derivative works or modified versions, and any portions
- * thereof, and that both notices appear in supporting documentation.
- *
- * THE COMPUTER SCIENCES DEPARTMENT OF THE UNIVERSITY OF WISCONSIN --
- * MADISON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS" CONDITION.
- * THE DEPARTMENT DISCLAIMS ANY LIABILITY OF ANY KIND FOR ANY DAMAGES
- * WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
- *
- * The EXODUS Project Group requests users of this software to return
- * any improvements or extensions that they make to:
- *
- * EXODUS Project Group
- * c/o David J. DeWitt and Michael J. Carey
- * Computer Sciences Department
- * University of Wisconsin -- Madison
- * Madison, WI 53706
- *
- * or exodus@cs.wisc.edu
- *
- * In addition, the EXODUS Project Group requests that users grant the
- * Computer Sciences Department rights to redistribute these changes.
- **********************************************************************/
-
-
- #include "sysdefs.h"
- #include "ess.h"
- #include "checking.h"
- #include "trace.h"
- #include "error.h"
- #include "list.h"
- #include "pool.h"
- #include "tid.h"
- #include "io.h"
- #include "lock.h"
- #include "object.h"
- #include "msgdefs.h"
- #include "thread.h"
- #include "semaphore.h"
- #include "latch.h"
- #include "link.h"
- #include "lsn.h"
- #include "bf.h"
- #include "volume.h"
- #include "openlog.h"
- #include "trans.h"
- #include "logrecs.h"
- #include "logaction.h"
- #include "log.h"
- #include "bitmap.h"
- #include "log_extfuncs.h"
- #include "recover_intfuncs.h"
- #include "trans_extfuncs.h"
- #include "analyze_extfuncs.h"
- #include "thread_globals.h"
- #include "trans_globals.h"
-
-
- /*
- * Determine the bitmap pages affected by allocation and deallocation
- * of pages
- */
-
- void
- analyzePageAllocation (
-
- LOGRECORDHDR *record
- )
- {
-
- register int i;
- PID *pid;
- int numPages;
- PID bitmapPid;
- PID headerPid;
- DIRTYPAGEINFO *dirtyInfo;
- int bitmapPageCount;
- LRC *lrcList;
- LRC *headerLRC; /* volume header lrc */
- SHORTPID allocPage;
- PAGEALLOCINFO *pageAllocInfo;
-
-
- TRACE(TR_IO, TR_LEVEL_1);
-
- /*
- * get a pointer to the page allocation info and the allocated pid
- */
- pageAllocInfo = (PAGEALLOCINFO*) GET_LOG_IMAGE(record, 0);
- pid = (PID *) GET_LOG_IMAGE(record, 1);
- numPages = GET_LOG_IMAGE_SIZE(record, 1) / sizeof(PID);
- TRPRINT(TR_RECOVER, TR_LEVEL_2, ("pid:%d", pid->page));
- TRPRINT(TR_RECOVER, TR_LEVEL_2, ("page2size:%d", pageAllocInfo->page2size));
-
- /*
- * If the pages are being deallocated, flag them in the
- * dirty page table. If they are being allocated,
- * then that is an internal error for now since no reallocation
- * of pages within a transaction is allowed.
- */
- for (i = 0; i < numPages; i++) {
- if ((dirtyInfo = searchDirtyPageTable( &(pid[i]) )) != NULL) {
- if (record->action == LOG_ACTION_DEALLOCATE_PAGE) {
- /*
- * flag the page as deallocated
- */
- SM_ASSERT(LEVEL_3, !(dirtyInfo->flags & DPT_DEALLOC) );
- dirtyInfo->flags |= DPT_DEALLOC;
- dirtyInfo->tid = record->tid;
- } else {
- SM_ASSERT(LEVEL_3, !(dirtyInfo->flags & DPT_DEALLOC) );
- }
-
- }
- }
-
- /*
- * get a pointer to the lrc list for the bitmap pages, and
- * calculate the number of bitmap pages involved, base on
- * the length of the list
- */
- lrcList = (LRC *) GET_LOG_IMAGE(record, 2);
- bitmapPageCount = GET_LOG_IMAGE_SIZE(record, 2) / sizeof(LRC);
- TRPRINT(TR_RECOVER, TR_LEVEL_2, ("lrc list size:%d", bitmapPageCount));
-
- /*
- * get a pointer to the volume header lrc and the pid of the
- * first bitmap page
- */
- headerLRC = &(pageAllocInfo->headerLRC);
- TRPRINT(TR_RECOVER, TR_LEVEL_2, ("header lrc:%d", headerLRC->count));
-
- /*
- * construct the bitmap pid
- */
- bitmapPid.volid = pid->volid;
-
- /*
- * check the pages for the dirty list
- */
- allocPage = pid->page; /* first allocated page */
- for (i = 0; i < bitmapPageCount; i++) {
-
- TRPRINT(TR_RECOVER, TR_LEVEL_2, ("block pid:%d", allocPage));
-
- /*
- * calculate the bitmap page
- */
- bitmapPid.page = BIT_TO_PAGE(allocPage) + pageAllocInfo->firstBitmapPage;
- TRPRINT(TR_RECOVER, TR_LEVEL_2, ("bitmap page:%d", bitmapPid.page));
- /*
- * Calculate index of the first allocated page on the next
- * bitmap page
- */
- allocPage += BITS_IN_PAGE - BIT_IN_PAGE(allocPage);
-
- /*
- * check to see if the page is in the dirty list
- */
- if ((dirtyInfo = searchDirtyPageTable( &bitmapPid )) == NULL) {
-
- /*
- * create a new entry
- */
- if ((dirtyInfo = insertDirtyPageTable( &bitmapPid )) == NULL) {
-
- SM_ERROR(TYPE_FATAL, esmINTERNAL);
- }
-
- /*
- * update the information
- */
- dirtyInfo->lsn = record->recordLSN;
- dirtyInfo->lrc = lrcList[i];
- TRPRINT(TR_RECOVER, TR_LEVEL_2, ("page lsn:%d, lrc:%d",
- dirtyInfo->lsn.offset, dirtyInfo->lrc.count));
- }
- }
-
- /*
- * Analyze the lrc on the header page, first get the header
- * page pid.
- */
- headerPid.page = pageAllocInfo->volumeHdrPage;
- headerPid.volid = pid->volid;
-
- /*
- * check to see if the header page is in the dirty list
- */
- if ((dirtyInfo = searchDirtyPageTable(&headerPid)) == NULL) {
-
- /*
- * create a new entry
- */
- if ((dirtyInfo = insertDirtyPageTable(&headerPid)) == NULL) {
-
- SM_ERROR(TYPE_FATAL, esmINTERNAL);
- }
-
- /*
- * update the information
- */
- dirtyInfo->lsn = record->recordLSN;
- dirtyInfo->lrc = *headerLRC;
- TRPRINT(TR_RECOVER, TR_LEVEL_2, ("lsn:%d,lrc:%d",
- dirtyInfo->lsn.offset, dirtyInfo->lrc.count));
- }
-
- }
-